import { getFaultChart , getFaultList } from '@/api/api'
const moduleFaultAlertChart = {
    state: {
        chartData:{
            chartId:1,
            title: '很多参数',
            paraList:['温度', '电压', '电流','网压','载重'],
            xAxisData: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
            datas:[{
                "name":"温度",
                data:[1,3,2,4,5,6,7]
            },{
                "name":"电压",
                data:[1,3,2,5,5,5,5]
            },{
                "name":"电流",
                data:[1,3,2,6,6,6,6]
            },{
                "name":"网压",
                data:[10,30,20,50,50,50,50]
            },{
                "name":"载重",
                data:[10,30,20,60,60,60,60]
            }]
        }
    },
    // mutations用于变更store中的数据
    // 通过mutations集中监控数据变更，利于维护
    // 不要在mutations异步函数
    mutations: {
        moduleFaultAlertChartData(state, chartData) {
            // console.log("000000", state.chartData,chartData);
            state.chartData = chartData;
            // console.log("000000", state.chartData);
        },
    },
    actions: {
        moduleFaultAlertChart({commit, dispatch}, params) {
            // console.log("~~faultAlert.js:",params)
            getFaultChart(params).then(res => {
                // console.log('参数weiwei为:',chartData);
                // console.log('请求车辆数据成功，返回数据weiwie为:');
                // console.log(res);
                commit('moduleFaultAlertChartData', res.data);
            }).catch(err => {
                console.log(err);
            });
        },
    },
    getters:{}
}
const moduleFaultAlertList = {
    state: {
            records:[{
                id: '1',
                lineCode:'GZML18',
                trainCode: '017018',
                coachNo: '1',
                systemCode: '牵引系统',
                faultLevel: '严重',
                faultCode: '9007',
                faultName: '电机1温度传感器故障',
                faultPart: ['电机滤网','电机轴承','电机温度传感器'],
                maintenanceAdvice: '运行结束后回库检修',
                happenTime: '2021-11-19 9:00',
                endTime: '2021-11-19 11:00',
                duration: '256s'
            }]
    },
    // mutations用于变更store中的数据
    // 通过mutations集中监控数据变更，利于维护
    // 不要在mutations异步函数
    mutations: {
        moduleFaultAlertListData(state, ListData) {
            // console.log("000000", state.chartData,chartData);
            state.records = ListData;
            // console.log("000000", state.chartData);
        },
    },
    actions: {
        moduleFaultAlertChart({commit, dispatch}, params) {
            // console.log("~~faultAlert.js:",params)
            getFaultList(params).then(res => {
                // console.log('参数weiwei为:',chartData);
                // console.log('请求车辆数据成功，返回数据weiwie为:');
                // console.log(res);
                commit('moduleFaultAlertListData', res.data);
            }).catch(err => {
                console.log(err);
            });
        },
    },
    getters:{}
}



export default moduleFaultAlertChart;